package com.qf.springboot.controller;


import com.qf.springboot.pojo.User;
import com.qf.springboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/users")
public class UserController {

    private UserService userService;

    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @GetMapping("/user/{id}")
    public User findUserById(@PathVariable Long id){
        User user = userService.findUserById(id);
        return user;

    }
    @PostMapping("/user")
    public User addUser(@RequestBody User user){
        return userService.addUser(user);

    }


}
